package com.chats.controller;


import com.chats.common.Result;
import com.chats.pojo.vo.MessageVO;
import com.chats.service.MessageService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/messages")
@Slf4j
@RequiredArgsConstructor //自动生成构造器
public class MessageController {

    private final MessageService messageService;

    /**
     * 查询历史消息
     * @return
     */
    @GetMapping("/list")
    public Result list(@RequestParam("fromId") Long fromId, @RequestParam("toId") Long toId) {
        log.info("获取历史消息列表 fromId={} toId={}", fromId, toId);
        List<MessageVO> list = messageService.historyList(fromId, toId);
        return Result.success(list);
    }




}
